package cn.tedu.helloword;

public class HelloWord {
    public static void main(String[] args) {
        Person[] p =new Person[5];
        Person p1 =new Teacher("王老师",25,1001);
        Person p2 =new Teacher("李老师",24,1002);
        Person p3 =new Student("张三",16,0123);
        Person p4 =new Student("李四",17,0124);
        Person p5 =new Student("王五",18,0125);
        p[0]=p1;
        p[1]=p2;
        p[2]=p3;
        p[3]=p4;
        p[4]=p5;
        for (int i = 0; i <p.length ; i++) {
            p[i].showMessage();
        }

    }
}
class Person{
    String name;
    int age;
    public Person(){
    }
    public Person(String name,int age){
        this.name=name;
        this.age=age;
    }
    public void showMessage(){
        System.out.println("展示某人的信息");
    }
}
 class Teacher extends Person {
     private int teacherld;

     public Teacher() {
     }

     public Teacher(String name, int age, int teacherld) {
         this.teacherld = teacherld;
         this.age = age;
         this.name = name;
     }

     public void showMessage() {
         System.out.println("老师的信息是: 姓名" + name + "年龄" + age + "工号" + teacherld);
     }
 }
     class Student extends Person {
        private int studentld;
        public Student(){}
        public Student(String name,int age,int studentld){
            this.studentld=studentld;
            this.age=age;
            this.name=name;
        }
         public void showMessage() {
             System.out.println("学生的信息是: 姓名" + name + "年龄" + age + "学号" + studentld);
         }
     }

